

import ColorType from "./enum/color";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Ball extends cc.Component {
    

    @property([cc.SpriteFrame])
    num: cc.SpriteFrame[] = Array<cc.SpriteFrame>();

    @property([cc.SpriteFrame])
    color: cc.SpriteFrame[] = Array<cc.SpriteFrame>();

    nowNum :number
    nowColor:ColorType

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {
       
    }

    setBallStyle(color?: ColorType, num?: number){
        if (color != null && num != null) {
            let bg = this.node.getChildByName('Background').getComponent(cc.Sprite)
            let ft = this.node.getChildByName('Background').getChildByName("font").getComponent(cc.Sprite)
            let ballbg = this.node.getComponent(cc.Button) as cc.Button
            ballbg.normalSprite = this.color[color]
            ballbg.pressedSprite = this.color[color]
            ballbg.disabledSprite = this.color[color]
            bg.spriteFrame = this.color[color]
            ft.spriteFrame = this.num[num - 1]
            this.nowNum = num
            this.nowColor = color
        } else {
            this.node.opacity = 0
        }
    }
    setPositionBll(arg0: cc.Vec2) {
        this.node.setPosition(arg0.x,arg0.y)
    }

    setScaleBall(num:number){
        this.node.setScale(num)
    }

    
    // update (dt) {}
}
